package com.pbc.gmp.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.pbc.gmp.commons.utils.PageInfo;
import com.pbc.gmp.dao.EquipmentdetailMapper;
import com.pbc.gmp.model.basemodel.Equipmentdetail;

import com.pbc.gmp.service.IEquipmentdetailService;

import com.xiaoleilu.hutool.convert.Convert;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author kjk
 * @since 2018-06-14
 */
@Service
public class EquipmentdetailServiceImpl extends ServiceImpl<EquipmentdetailMapper, Equipmentdetail> implements IEquipmentdetailService {

    @Resource(name="equDao")
    private EquipmentdetailMapper equDao;

    @Override
    public void selectEquipmentDetailByDetailWhere(PageInfo pageInfo) {
        Page<Map<String, Object>> page = new Page<Map<String, Object>>(pageInfo.getNowpage(), pageInfo.getSize());
        List<Map<String, Object>> list = equDao.selectEquipmentDetailByDetailWhere(page, pageInfo.getCondition());
        for (Map<String, Object> row:list ) {

            row.put("eqid",row.get("id").toString());



        }
        pageInfo.setRows(list);
        pageInfo.setTotal(page.getTotal());
    }

    @Override
    public void deleteBatchByIds(String ids) {
        String[] idlist =ids.split(",");

        for (String id : idlist) {
            this.deleteById(Convert.toLong(id));
        }
    }
}
